﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class OMailLineTempleteEdit : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改 };
            }
        }
        protected override string DWZRef
        {
            get { return "OMailLineTempleteList"; }
        }

        #region
        /// <summary>
        /// 需要修改的ID
        /// </summary>
        protected int MLTID
        {
            get
            {
                return GetRequestValue<int>("MLTID");
            }
        }

        private OMailLineTempleteInfo _obj;
        protected OMailLineTempleteInfo obj
        {
            get
            {
                if (_obj == null)
                {
                    List<OMailLineTempleteInfo> lis =OMailLineController.GetAllOMailLineTemplete();
                    _obj = lis.First(e => e.MLTID == MLTID);
                    // _obj = UMacKeepController.UMacKeepConfig_GetALL(ID);
                }
                return _obj;
                //OMenuController.ge
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu();
            }
            

        }

        protected void addmenu()
        {
            OMailLineTempleteInfo obx = Request.SerializableObject<OMailLineTempleteInfo>();

            if (OMailLineController.UpdateOMailLineTemplete(obx))
            {
                SuccessJson("修改成功", DWZRef);
            }
            else
                ErrorJson("修改失败", DWZRef);
        }

        protected string GetNGSelect(string controlName, string selectvalue)
        {
            string selectHtml = "";//;"<select name=\"NG_铁履H前10m\"><option value=\"OK\" selected>OK</option><option value="NG->OK">NG->OK</option><option value="NG">NG</option></select>";
            string[] ngItme = new string[] { "OK", "NG", "NG->OK", };
            foreach (string item in ngItme)
            {
                selectHtml += string.Format("<option value=\"{0}\" {1}>{0}</option>", item, item == selectvalue ? "selected" : "");
            }
            return string.Format("<select name=\"{1}\">{0}</select>", selectHtml, controlName);
        }
        
    }
}